Skip to content

Conversation

Azoy
Copy link
Contributor

@Azoy Azoy commented Sep 22, 2025

This adds a new experimental feature DefaultGenerics that allows you to add default types to generic parameters on types.

struct UniqueArray<Element: ~Copyable, Alloc: Allocator = SystemAllocator> {}

You can explicitly specialize said types with all of their generic parameters, or just the required ones.

Rules:

  • All defaulted generic parameters must be trailing every other parameter
  • There must not be a parameter pack and a default generic parameter present
  • Currently only limited to type parameters (value parameters could be supported in the future)
  • Generic parameters can only have default types when they are on generic type declarations (or extensions). I.e. generic functions cannot introduce a generic parameter and have a default type.

Corresponding swift-syntax PR here: swiftlang/swift-syntax#3152

Resolves: rdar://160474830

@Azoy
Copy link
Contributor Author

Azoy commented Sep 22, 2025

@swift-ci please smoke test

@Azoy
Copy link
Contributor Author

Azoy commented Sep 23, 2025

swiftlang/swift-syntax#3152
@swift-ci please smoke test

@Azoy
Copy link
Contributor Author

Azoy commented Sep 23, 2025

swiftlang/swift-syntax#3152
@swift-ci please smoke test

@Azoy
Copy link
Contributor Author

Azoy commented Sep 23, 2025

@swift-ci please smoke test

@Azoy
Copy link
Contributor Author

Azoy commented Sep 23, 2025

swiftlang/swift-syntax#3152
@swift-ci please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant